'use strict';

const Controller = require('egg').Controller;

class ContentController extends Controller {

  async list() {
    this.ctx.validate({
        liveid: {
          type: "int",
          required: true,
          defValue: "",
          desc: "liveid",
        },
      })
      const res = await this.app.model.Comment.findAll({
        where: {
          live_id: this.ctx.request.body.liveid
        },
        include:[{
          model:this.app.model.User,
    
          attributes:["id","username","avatar","name"]
        },
        {
          model:this.app.model.Live,
    
          attributes:["id","title","cover"]
        }]
      })
     
      this.ctx.apiSuccess(res,"获取成功",200)
    }
  async closezb(){
    this.ctx.validate({
        id: {
          type: "int",
          required: true,
          defValue: "",
          desc: "liveid",
        },
      })
      const res = await this.app.model.Live.findOne({
        where: {
          id: this.ctx.request.body.id
        },
        
      })
        res.status =3
        res.save()

      
      this.ctx.apiSuccess(res,"关闭成功",200)
  }
}

module.exports = ContentController;
